import java.util.LinkedList;
import java.util.List;


public class Tetris {

	public static class Position{
		public 	int X;
		public 	int Y;
		public Position(int x, int y){
			X = x;
			Y = y;
		}
		
		
		@Override
		public boolean equals(Object obj) {
			if (this == obj){
				return true;
			}
			if (!(obj instanceof Position) || null == obj ) 
				return false;
			Position other =(Position)obj;
			
			return this.X == other.X && this.Y == other.Y;
		}


		@Override
		public String toString() {
			return String.format("[%d, %d]", X, Y);
		}
		
	}
	
	public static class Glass{
		private final int countColumns;
		private final int countRows;
		private final char[][] glassMatrixs;

		public Glass(String glass, int columns, int rows){
			countColumns = columns;
			countRows = rows;
			
			if (glass.length() != columns * rows){throw new RuntimeException("invalid parameter");}
			
			glassMatrixs = this.transformGlass(glass);
		}
		
		private char[][] transformGlass(String glass) {
		    char s[][] = new char[countRows][countColumns];
		    for(int i=0; i < countRows; i++){
		        int begin = i*countColumns;
		        int end = i*countColumns + countColumns;
		        String line = glass.substring(begin, end);
		        s[i] = line.toCharArray();
		    }
		    return s;
		}
		
		
		
		public int getColumnsCount(){
			return countColumns;
		}
		
		public int getRowsCount(){
			return countRows;
		}

		public char getItem(int column, int row) {
			return glassMatrixs[column][row];
		}
		
		public void setItem(int column, int row, char ch) {
			glassMatrixs[column][row] = ch;
		}

		public void placeFigure(Glass lineGlass, int x) {	
			
		}

		public List<Position> findPositions(FigureMask iMask) {
			
			List<Position> result = new LinkedList<Position>();
			
			Integer[] surface = this.createSurface();
			
			
			for(int x = 0; x < surface.length; x++){
				int y = (surface[x] != null) ? surface[x] : -1;

				Position position = new Position(x, y + 1);
				if (iMask.canSuccessPalceFigure(position, this)){
					result.add( position );
				}
			}
			
			return result;
		}

		public Integer[] createSurface() {
			Integer[] surfGlass = new Integer[ this.getColumnsCount() ];
			
			for (int currColumn = 0; currColumn < this.getColumnsCount(); currColumn++){
				for (int currRow = 0; currRow < this.getRowsCount(); currRow++){
					
					//System.out.println( "[ " + currColumn + ", " + currRow + " ] " + this.getItem(currRow, currColumn ));
					
					if (this.getItem(currRow, currColumn) == '*'){
						surfGlass[currColumn] = currRow;
					}
				}
			}
			
			return surfGlass;
		}
		
		void print(){
	        System.out.println("----------");
	        for (int i = 0; i < glassMatrixs.length; i++) {
	            for (int j = 0; j < glassMatrixs[i].length; j++) {
	                System.out.print(glassMatrixs[i][j]);
	            }
	            System.out.println("");
	        }
	        System.out.println("----------");
	    }
	}

	static class IFigure extends FigureAction {
		
		private char[][] figureNeedSurface;
		
		//I
		final char[][] iSurface0  = new char[][]{ 
				{ 'X' }, 
				{ '*' },
				};
		final char[][] iSurface90 = new char[][]{ 
				{ 'X' , 'X' ,'X' ,'X' },
				{ '*' , '*' ,'*' ,'*' }
				};
		final char[][] iSurface180 = iSurface0;
		final char[][] iSurface270 = iSurface90;
		
//		// O
//		final char[][] oSurface0 = new char[][]{ 
//				{ 'X' , 'X' }, 
//				{ '*' , '*' }
//				};
//		final char[][] oSurface90 = oSurface0;
//		final char[][] oSurface180 = oSurface0;
//		final char[][] oSurface270 = oSurface0;
		
		
//		// L
//		final char[][] lSurface0 = new char[][]{ 
//				{ 'X' , 'X' },
//				{ '*' , '*' }
//				};
//		final char[][] lSurface90 = new char[][]{
//				{ 'X' , 'X', 'X' },
//				{ 'X' , '*', '*' }, 
//				{ '*' , ' ', ' ' }
//				};
//		final char[][] lSurface180 = new char[][]{
//				{ 'X' , 'X' },
//				{ '*' , 'X' },
//				{ '*' , 'X' },
//				{ '*' , '*' }
//				};
//		final char[][] lSurface270 = new char[][]{
//				{ 'X' , 'X' , 'X' },
//				{ '*' , '*' , '*' }
//				};
		
		
		public IFigure(){
		}
		
		public FigureAction calculatePosition(int x, int y, Glass glass){
			
			return this;
        }
    }
	
	
	static class FigureAction {
        private int left   = 0;
        private int right  = 0;
        private int rotate = 0;
        private boolean drop = false;
        
        public void setLeft(int left) {
            this.left = left;
        }

        public void setRight(int right) {
            this.right = right;
        }

        public void setRotate(int rotate) {
            this.rotate = rotate;
        }

        public void setDrop(boolean drop) {
            this.drop = drop;
        }

        public int getLeft() {
			return left;
		}

		public int getRight() {
			return right;
		}

		public int getRotate() {
			return rotate;
		}

		public boolean isDrop() {
			return drop;
		}

		public String answer(){
            StringBuilder sb = new StringBuilder("");
            sb.append("left=" + left);
            sb.append(", right=" + right);
            sb.append(", rotate=" + rotate);
            if (drop){
                sb.append(", drop");
            }
            return sb.toString();
        }

    }
	
	
	
	public FigureAction answer(String figure, int x, int y, String glassString) {

		Glass glass = new Glass(glassString, 10, 20);
		
		if (figure.equalsIgnoreCase("I")){
			IFigure line = new IFigure();
			line.calculatePosition(x, y, glass);
			return line;
		}
		
		FigureAction action = new FigureAction();
		action.setDrop(true);
		return action;
	}
		
	
}
